package guda.house.biz.form.rule;

import guda.house.biz.util.PriceUtil;
import guda.house.dal.dataobject.WaterRuleDO;

import javax.validation.constraints.NotNull;

/**
 * Created by well on 15/11/11.
 */
public class WaterRuleEditForm extends WaterRuleForm{
    @NotNull(message = "不能为空")
    private Long ruleId;

    public Long getRuleId() {
        return ruleId;
    }

    public void setRuleId(Long ruleId) {
        this.ruleId = ruleId;
    }

    public void initForm(WaterRuleDO waterRuleDO){
        setRuleId(waterRuleDO.getRuleId());
        setMaxValue(waterRuleDO.getMaxValue());
        setRuleName(waterRuleDO.getRuleName());
        setRuleStatus(waterRuleDO.getRuleStatus());
        setMinValue(waterRuleDO.getMinValue());
        setFeeUnit(PriceUtil.formatCNY(waterRuleDO.getFeeUnit()));
        setVillageId(waterRuleDO.getVillageId());
        setBuildingTypeId(waterRuleDO.getBuildingTypeId());

    }

    public WaterRuleDO toDO(){
        WaterRuleDO waterRuleDO = super.toDO();
        waterRuleDO.setRuleId(ruleId);
        return waterRuleDO;
    }
}
